package map.gui.abstraction;

import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Point;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.StringTokenizer;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextArea;
import javax.swing.JTree;
import javax.swing.border.BevelBorder;
import javax.swing.filechooser.FileFilter;
import javax.swing.tree.DefaultMutableTreeNode;

import map.abstractor.main.Main;
import map.abstractor.uimodel.ModelXML2UIModel;
import map.gui.main.MainWindow;
import map.gui.util.ModelViewer;
import map.gui.util.Utils;
import map.gui.util.XMLTreeViewer;
import map.tools.interactions.WidgetBehaviorTable;
import map.tools.plateform.MappingTableSerializer;
import map.tools.uimodel.UIModelSeriralizer;
import map.tools.uimodel.WidgetsModelsSerializer;
import map.tools.uimodel.XMLModelSerialiser;
import uimigration.UIModel.UIModel;
import uimigration.WidgetsModel.APIModel;
import uimigration.xmluimodel.Object;


public class AbstractUI extends JFrame {

	private static final long serialVersionUID = 1L;
	public static final String XMLFILESPATH=".//models//xml//"; 
	public static final String UIMODELFILESPATH=".//models//ui//";  //  @jve:decl-index=0:
	public static final String APIFILESPATH=".//models//api//";
	public static final String DEVICEFILESPATH=".//models//device//";  //  @jve:decl-index=0:
	public static final String TABLEFILESPATH="models//tables//";  //  @jve:decl-index=0:
	public static final String XSDFILESPATH="models//xsd//";  //  @jve:decl-index=0:
		
	private JPanel jContentPane = null;
	private JButton jButtonChoose = null;
	private  JFileChooser fc=null ;
	private JPanel jPanelCode = null;
	private JPanel jPanelUIModel = null;
	private JScrollPane codeJscrollPane= null;
	private JTextArea textArea= null;
	private JLabel UIModelLabel = null;
	private JButton abstractButton = null;
	private JButton SaveButton = null;
	private JScrollPane jScrollPaneUIModel = null;
	private JTree UIModelTree1 = null;
	private JSplitPane jSplitPane = null;
	private JLabel urlLabel1 = null;
	private JLabel urlLabel2 = null;
	protected static String uimodelFile=null;
	protected static String xmlmodelFile=null;
	protected static File apiModelFile=null;
	protected static String apiMappingFile=null;
	private JButton abstractUIModelButton = null;
	public MainWindow parent=null;
	private JSplitPane jSplitPaneModel = null;
	private JPanel XMLModelPanel = null;
	private JPanel UIModelPanel = null;
	private JLabel XMLModelLabel1 = null;
	private JScrollPane jScrollPaneXMLModel = null;
	private JTree XMLModelTree1 = null;
	private JButton validateButton = null;
	private XMLTreeViewer treev= null;  //  @jve:decl-index=0:
	private XMLTreeViewer treev1= null;  //  @jve:decl-index=0:
	private JButton jButtonValidate = null;

	/**
	 * This is the default constructor
	 */
	public AbstractUI(MainWindow parent) {
		super();
		this.parent= parent;
		initialize();
		
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(700, 500);
		this.setResizable(true);
		this.setLocation(new Point(320, 320));
		this.setContentPane(getJContentPane());
		this.setTitle("Abstraction");
		this.setVisible(true);
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			GridLayout gridLayout = new GridLayout();
			gridLayout.setRows(1);
			jContentPane = new JPanel();
			jContentPane.setLayout(gridLayout);
			jContentPane.add(getJSplitPane(), null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes jPanelFile	
	 * 	
	 * @return javax.swing.JPanel	
	 */

	/**
	 * This method initializes jButtonChoose	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonChoose() {
		if(fc==null)
			fc = new JFileChooser();
			fc.addChoosableFileFilter(new FileFilter() {
				public boolean accept(File f) {
				    if (f.isDirectory()) {
					return true;
				    }

				    String extension = Utils.getExtension(f);
				    if (extension != null) {
				    	boolean eq=false;
				    	for(int i=0; i<Utils.extensions.length;i++)
				    		if(extension.equals(Utils.extensions[i]))
				    			eq=true;
					        return eq;
				    }
				    return false;
				}

				 //The description of this filter
			    public String getDescription() {
			        return "Just Texts";
			    }
			});

		if (jButtonChoose == null) {
			jButtonChoose = new JButton();
			jButtonChoose.setText("Choose File ...");
			jButtonChoose.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
				    if (e.getSource() == jButtonChoose) {
				        int returnVal = fc.showOpenDialog(AbstractUI.this);
				        //System.out.println(returnVal+" "+JFileChooser.APPROVE_OPTION);
				        if (returnVal == JFileChooser.APPROVE_OPTION) {
				            //System.out.println(file.getAbsolutePath()+" "+fc.getSelectedFile().getAbsoluteFile());
				            urlLabel2.setText(fc.getSelectedFile().getAbsolutePath());
				            try {
								textArea.setText(ModelViewer.getFileContent(urlLabel2.getText()));
							} catch (FileNotFoundException e1) {
								e1.printStackTrace();
							}
				            
				            //This is where a real application would open the file.
				            //log.append("Opening: " + file.getName() + "." + newline);
				        } else {
				            //log.append("Open command cancelled by user." + newline);
				        }
				   }
				}
			});
		}
		return jButtonChoose;
	}

	/**
	 * This method initializes jPanelCode	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanelCode() {
		if (jPanelCode == null) {
			GridBagConstraints gridBagConstraints14 = new GridBagConstraints();
			gridBagConstraints14.gridx = 3;
			gridBagConstraints14.gridy = 2;
			GridBagConstraints gridBagConstraints41 = new GridBagConstraints();
			gridBagConstraints41.gridx = 1;
			gridBagConstraints41.gridy = 1;
			urlLabel2 = new JLabel();
			urlLabel2.setText("choose file");
			urlLabel2.setToolTipText("source  file to abstract");
			GridBagConstraints gridBagConstraints31 = new GridBagConstraints();
			gridBagConstraints31.gridx = 0;
			gridBagConstraints31.gridy = 1;
			urlLabel1 = new JLabel();
			urlLabel1.setText("File url");
			GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
			gridBagConstraints11.gridx = 0;
			gridBagConstraints11.gridwidth = 2;
			gridBagConstraints11.gridy = 2;
			GridBagConstraints gridBagConstraints8 = new GridBagConstraints();
			gridBagConstraints8.gridx = 2;
			gridBagConstraints8.gridheight = 1;
			gridBagConstraints8.gridwidth = 1;
			gridBagConstraints8.gridy = 1;
			GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
			gridBagConstraints4.gridx = 3;
			gridBagConstraints4.gridy = 1;
			GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
			gridBagConstraints2.gridx = 0;
			gridBagConstraints2.gridy = 1;
			GridBagConstraints gridBagConstraints = new GridBagConstraints();
			gridBagConstraints.gridx = -1;
			gridBagConstraints.gridy = -1;
			GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
			gridBagConstraints3.fill = GridBagConstraints.BOTH;
			gridBagConstraints3.gridy = 3;
			gridBagConstraints3.weightx = 2.0D;
			gridBagConstraints3.weighty = 1.0;
			gridBagConstraints3.gridwidth = 4;
			gridBagConstraints3.gridx = 0;
			jPanelCode = new JPanel();
			jPanelCode.setLayout(new GridBagLayout());
			//jPanelCode.setPreferredSize(new Dimension(this.getWidth()/3 + 20, 0));
			jPanelCode.add(getCodeTextArea(), gridBagConstraints3);
			jPanelCode.add(getJButtonChoose(), gridBagConstraints4);
			jPanelCode.add(getAbstractButton(), gridBagConstraints11);
//			jPanelCode.add(jLabel1, gridBagConstraints2);
			jPanelCode.add(urlLabel1, gridBagConstraints31);
			jPanelCode.add(urlLabel2, gridBagConstraints41);
			jPanelCode.add(getAbstractUIModelButton(), gridBagConstraints14);
		}
		return jPanelCode;
	}

	/**
	 * This method initializes jPanelUIModel	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanelUIModel() {
		if (jPanelUIModel == null) {
			GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
			gridBagConstraints1.fill = GridBagConstraints.BOTH;
			gridBagConstraints1.gridy = -1;
			gridBagConstraints1.weightx = 1.0;
			gridBagConstraints1.weighty = 1.0;
			gridBagConstraints1.gridx = -1;
			UIModelLabel = new JLabel();
			UIModelLabel.setText("UIModel");
			jPanelUIModel = new JPanel();
			jPanelUIModel.setLayout(new GridBagLayout());
			//jPanelUIModel.setPreferredSize(new Dimension(this.getWidth()/3 + 20, 0));
			jPanelUIModel.add(getJSplitPaneModel(), gridBagConstraints1);
		}
		return jPanelUIModel;
	}

	/**
	 * This method initializes codeTextArea	
	 * 	
	 * @return javax.swing.JTextArea	
	 */
	private JScrollPane getCodeTextArea() {
		if (codeJscrollPane == null) {
			codeJscrollPane = new JScrollPane(gettextArea());
			codeJscrollPane.setPreferredSize(new Dimension(800, 600));
			codeJscrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
			codeJscrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
			//jScrollPaneUIModel.setViewportView(getUIModelTree1());
			codeJscrollPane.setViewportView(gettextArea());
			codeJscrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
			codeJscrollPane.setViewportBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
			codeJscrollPane.setPreferredSize(new Dimension(60, 22));
			codeJscrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

		}
		return codeJscrollPane;
	}
	private JTextArea gettextArea()
	{
		if(textArea==null)
		{
			textArea=new JTextArea();
			setPreferredSize(new Dimension(700, 300));
		}
		return  textArea;
	}
	

	/**
	 * This method initializes abstractButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getAbstractButton() {
		if (abstractButton == null) {
			abstractButton = new JButton();
			abstractButton.setText("Abstract XML Model");
			abstractButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					//Abstraction code
					File dir= new File(XMLFILESPATH);
					int i=0;
					if(dir.isDirectory())
						i=dir.listFiles().length;
					File oldFile= new File(urlLabel2.getText());
					StringTokenizer st=new StringTokenizer(oldFile.getName(),".");
					String names=(String) st.nextToken();
					String xmlname="";
					String uiname="";
					if(names==null )
					{	
						xmlname=XMLFILESPATH+"XMLModel"+i+".xmi";
						uiname=UIMODELFILESPATH+"UIModel"+i+".xmi";
					}
					else
					{	
						xmlname=XMLFILESPATH+names+i+".xmi";
						uiname=UIMODELFILESPATH+names+i+".xmi";
					}
					try {
						String content=Main.Xaml2Model(urlLabel2.getText()).toString();
						//content ="<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"+content;
						
						Main.saveFile(xmlname, content);
					} catch (IOException e2) {
						e2.printStackTrace();
					}
					//TODOXaml2Model: Insert Abstraction code here
					validateButton.setEnabled(true);
					abstractUIModelButton.setEnabled(true);
					XMLModelTree1.setVisible(true);
					uimodelFile=uiname;
					xmlmodelFile=xmlname;
					if(xmlmodelFile!=null)
					{
						try {
							treev.xmlSetUp(new File(xmlmodelFile));
						} catch (Exception e1) {
							e1.printStackTrace();
						}
					}
				}
			});
		}
		return abstractButton;
	}

	/**
	 * This method initializes SaveButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getSaveButton() {
		if (SaveButton == null) {
			SaveButton = new JButton();
			SaveButton.setText("Save Model");
			SaveButton.setPreferredSize(new Dimension(99, 26));
			SaveButton.setEnabled(false);
			SaveButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					//System.out.println("actionPerformed()"); 
					parent.apiFile= apiModelFile.getName();
					parent.setUiModel(( new File(uimodelFile)).getName());
				    DefaultMutableTreeNode top = new DefaultMutableTreeNode("UIModel Project");
				    DefaultMutableTreeNode uimodel = new DefaultMutableTreeNode("UIModel files");
				    DefaultMutableTreeNode apimodel = new DefaultMutableTreeNode("API Models files");
				    uimodel.add( new DefaultMutableTreeNode(parent.getUiModel()));
				    apimodel.add(new DefaultMutableTreeNode(parent.apiFile));
				    top.add(uimodel);
				    top.add(apimodel);
				    parent.getJPanelProject().removeAll();
					GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
					gridBagConstraints11.fill = GridBagConstraints.BOTH;
					gridBagConstraints11.gridy = 0;
					gridBagConstraints11.weightx = 1.0;
					gridBagConstraints11.weighty = 1.0;
					gridBagConstraints11.gridx = 0;
				    parent.getJPanelProject().add(parent.getProjectTree(top), gridBagConstraints11);;
				    AbstractUI.this.dispose();
					
				}
			});
		}
		return SaveButton;
	}



	/**
	 * This method initializes jScrollPaneUIModel	
	 * 	
	 * @return javax.swing.JScrollPane	
	 */
	private JScrollPane getJScrollPaneUIModel() {
		if (jScrollPaneUIModel == null) {
			jScrollPaneUIModel = new JScrollPane(getUIModelTree1());
			jScrollPaneUIModel.setPreferredSize(new Dimension(600, 300));
			jScrollPaneUIModel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
			jScrollPaneUIModel.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
			//jScrollPaneUIModel.setViewportView(getUIModelTree1());
			jScrollPaneUIModel.setViewportView(getUIModelTree1());
			jScrollPaneUIModel.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
			jScrollPaneUIModel.setViewportBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
			jScrollPaneUIModel.setPreferredSize(new Dimension(600, 22));
			jScrollPaneUIModel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		}
		return jScrollPaneUIModel;
	}

	/**
	 * This method initializes UIModelTree1	
	 * 	
	 * @return javax.swing.JTree	
	 */
	private JTree getUIModelTree1() {
		if (UIModelTree1 == null) {
			UIModelTree1 = new JTree();
			if(treev1==null)
				treev1= new XMLTreeViewer(UIModelTree1);
			UIModelTree1.setVisible(false);
			UIModelTree1.setPreferredSize(new Dimension(600, 1200));
			UIModelTree1.setVisibleRowCount(10);
			UIModelTree1.setShowsRootHandles(true);
			//UIModelTree1.setVisible(true);
		}
		return UIModelTree1;
	}

	/**
	 * This method initializes jSplitPane	
	 * 	
	 * @return javax.swing.JSplitPane	
	 */
	private JSplitPane getJSplitPane() {
		if (jSplitPane == null) {
			jSplitPane = new JSplitPane();
			jSplitPane.setDividerLocation(300);
			jSplitPane.setContinuousLayout(true);
			jSplitPane.setLeftComponent(getJPanelCode());
			jSplitPane.setRightComponent(getJPanelUIModel());
		}
		return jSplitPane;
	}

	/**
	 * This method initializes abstractUIModelButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getAbstractUIModelButton() {
		if (abstractUIModelButton == null) {
			abstractUIModelButton = new JButton();
			abstractUIModelButton.setPreferredSize(new Dimension(148, 26));
			abstractUIModelButton.setEnabled(false);
			abstractUIModelButton.setText("Abstract UI Model");
			abstractUIModelButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					//System.out.println("actionPerformed()"); // 
					if(xmlmodelFile!=null)
					{
						if(apiMappingFile==null)
							apiModelFile=new File(APIFILESPATH+"APIModelXAML_PC.xmi");
						
						APIModel api= (new WidgetsModelsSerializer()).load(apiModelFile);	
						WidgetBehaviorTable table = new WidgetBehaviorTable(new MappingTableSerializer().load(( new File(TABLEFILESPATH+"MappingTable.xmi"))));
						Object xmlmodel= (new XMLModelSerialiser().load(new File(xmlmodelFile)));
							try {
							ModelXML2UIModel modelprocess= new ModelXML2UIModel(xmlmodel,api,table);
							UIModel uimodel=modelprocess.abstractUIModel();
							(new UIModelSeriralizer()).save(uimodel, uimodelFile);
							treev1.xmlSetUp(new File(uimodelFile));
							UIModelTree1.setVisible(true);
							UIModelLabel.setText("UI Model");
							SaveButton.setEnabled(true);
							jButtonValidate.setVisible(true);
							

						} catch (Exception e1) {
						
							e1.printStackTrace();
						}
					}
				}
			});
		}
		return abstractUIModelButton;
	}

	/**
	 * This method initializes jSplitPaneModel	
	 * 	
	 * @return javax.swing.JSplitPane	
	 */
	private JSplitPane getJSplitPaneModel() {
		if (jSplitPaneModel == null) {
			jSplitPaneModel = new JSplitPane();
			jSplitPaneModel.setDividerLocation(160);
			jSplitPaneModel.setLeftComponent(getXMLModelPanel());
			jSplitPaneModel.setRightComponent(getUIModelPanel());
		}
		return jSplitPaneModel;
	}

	/**
	 * This method initializes XMLModelPanel	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getXMLModelPanel() {
		if (XMLModelPanel == null) {
			GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
			gridBagConstraints10.gridx = 0;
			gridBagConstraints10.gridy = 2;
			GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
			gridBagConstraints9.fill = GridBagConstraints.BOTH;
			gridBagConstraints9.weighty = 1.0;
			gridBagConstraints9.gridx = 0;
			gridBagConstraints9.gridy = 1;
			gridBagConstraints9.weightx = 1.0;
			XMLModelLabel1 = new JLabel();
			XMLModelLabel1.setText("XMLModel");
			XMLModelPanel = new JPanel();
			XMLModelPanel.setLayout(new GridBagLayout());
			XMLModelPanel.add(XMLModelLabel1, new GridBagConstraints());
			XMLModelPanel.add(getValidateButton(), gridBagConstraints10);
			XMLModelPanel.add(getJScrollPaneXMLModel(), gridBagConstraints9);
		}
		return XMLModelPanel;
	}

	/**
	 * This method initializes UIModelPanel	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getUIModelPanel() {
		if (UIModelPanel == null) {
			GridBagConstraints gridBagConstraints12 = new GridBagConstraints();
			gridBagConstraints12.gridy = 2;
			GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
			gridBagConstraints7.gridx = 0;
			gridBagConstraints7.gridy = 2;
			GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
			gridBagConstraints6.fill = GridBagConstraints.BOTH;
			gridBagConstraints6.gridy = 1;
			gridBagConstraints6.weightx = 2.0D;
			gridBagConstraints6.weighty = 1.0;
			gridBagConstraints6.gridwidth = 2;
			gridBagConstraints6.gridx = 0;
			GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
			gridBagConstraints5.gridx = 0;
			gridBagConstraints5.gridy = 0;
			UIModelPanel = new JPanel();
			UIModelPanel.setLayout(new GridBagLayout());
			UIModelPanel.add(UIModelLabel, gridBagConstraints5);
			UIModelPanel.add(getJScrollPaneUIModel(), gridBagConstraints6);
			UIModelPanel.add(getSaveButton(), gridBagConstraints7);
			UIModelPanel.add(getJButtonValidate(), gridBagConstraints12);
		}
		return UIModelPanel;
	}

	/**
	 * This method initializes XMLModelTree1	
	 * 	
	 * @return javax.swing.JTree	
	 */
	private JTree getXMLModelTree1() {
		if (XMLModelTree1 == null) {
			XMLModelTree1 = new JTree( );
			if(treev==null)
				treev= new XMLTreeViewer(XMLModelTree1);
			XMLModelTree1.setPreferredSize(new Dimension(600, 1200));
			XMLModelTree1.setShowsRootHandles(true);
			XMLModelTree1.setVisibleRowCount(10);
			//XMLModelTree1.setVisible(true);
		}
		return XMLModelTree1;
	}

	/**
	 * This method initializes jScrollPaneXMLModel	
	 * 	
	 * @return javax.swing.JScrollPane	
	 */
	private JScrollPane getJScrollPaneXMLModel() {
		if (jScrollPaneXMLModel == null) {
			jScrollPaneXMLModel = new JScrollPane(getXMLModelTree1());
			jScrollPaneXMLModel.setPreferredSize(new Dimension(600, 300));
			jScrollPaneXMLModel.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
			jScrollPaneXMLModel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
			jScrollPaneXMLModel.setViewportBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
			jScrollPaneXMLModel.setViewportView(getXMLModelTree1());
		}
		return jScrollPaneXMLModel;
	}

	/**
	 * This method initializes validateButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getValidateButton() {
		if (validateButton == null) {
			validateButton = new JButton();
			validateButton.setText("Validate");
			validateButton.setEnabled(false);
			validateButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					String message;
					message = new XMLModelSerialiser().validate(xmlmodelFile);
					JOptionPane.showMessageDialog(AbstractUI.this, message);
				}
			});
		}
		return validateButton;
	}

	/**
	 * This method initializes jButtonValidate	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonValidate() {
		if (jButtonValidate == null) {
			jButtonValidate = new JButton();
			jButtonValidate.setText("Validate");
			jButtonValidate.setVisible(false);
			jButtonValidate.addActionListener(new java.awt.event.ActionListener() {   
				public void actionPerformed(java.awt.event.ActionEvent e) {    
					String message;
					message = new UIModelSeriralizer().validate(uimodelFile);
					JOptionPane.showMessageDialog(AbstractUI.this, message);

				}
			
			});
		}
		return jButtonValidate;
	}

}
